﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Enter.BizLogic;
using Enter.Entity;
using System.Data;
using Enter.Config;

namespace Enter.Services.Mail
{
    public partial class Mail : IMail
    {
        #region 购物车

        /// <summary>
        /// 添加购物车
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool AddCar(T303_Order_CartEntity entity)
        {
            T303_Order_CartBLLSub bll = new T303_Order_CartBLLSub();
           return bll.Save(entity);
        }
        /// <summary>
        /// 添加购物车
        /// </summary>
        /// <param name="Entitys"></param>
        /// <returns></returns>
        public bool AddCar(List<T303_Order_CartEntity> Entitys)
        {
            T303_Order_CartBLLSub bll = new T303_Order_CartBLLSub();
            return bll.Save(Entitys);
        }
        /// <summary>
        /// 修改购物车状态
        /// </summary>
        /// <returns></returns>
        public bool UpdateCartStatus(int id, int UID, Enter.Entity.T303_Order_CartEntity.EnumStatus status)
        {
            T303_Order_CartBLLSub bll = new T303_Order_CartBLLSub();
            return bll.UpdateCartStatus(id, UID, status);
        }
        /// <summary>
        /// 修改购物车状态
        /// </summary>
        /// <returns></returns>
        public bool UpdateCartStatus(string ids, int UID, Enter.Entity.T303_Order_CartEntity.EnumStatus status)
        {
            T303_Order_CartBLLSub bll = new T303_Order_CartBLLSub();
            return bll.UpdateCartStatus(ids, UID, status);
        }
         /// <summary>
        /// 批量删除
        /// </summary>
        /// <returns></returns>
        public bool DelCart(string ids, int UID)
        {
            T303_Order_CartBLLSub bll = new T303_Order_CartBLLSub();
            return bll.Delete(ids, UID);
        }
        /// <summary>
        /// 清空用户购物车
        /// </summary>
        /// <returns></returns>
        public bool ClareAll(int uID)
        {
            T303_Order_CartBLLSub bll = new T303_Order_CartBLLSub();
            return bll.ClareAll(uID);
        }
        /// <summary>
        /// 修改购物车商品数量
        /// </summary>
        /// <param name="carID">购物车ID</param>
        /// <param name="goodNum">商品数量</param>
        /// <returns></returns>
        public bool UpdateCartCount(int carID, int UID, int goodNum)
        {
            T303_Order_CartBLLSub bll = new T303_Order_CartBLLSub();
            return bll.UpdateCartCount(carID, UID, goodNum);
        }
        /// <summary>
        /// 获取用户购物车
        /// </summary>
        /// <param name="uID"></param>
        /// <returns></returns>
        public DataTable GetUserCar(int uID)
        {
            T303_Order_CartBLLSub bll = new T303_Order_CartBLLSub();
           
            return bll.GetUserCar(uID);
        }
        public DataTable GetUserCar(int uID, string ids)
        {
            T303_Order_CartBLLSub bll = new T303_Order_CartBLLSub();

            return bll.GetUserCar(uID, ids);
        }
#endregion

        #region 订单
        public string GetOrderNo()
        {
            int num = new Random().Next(100, 0x270f);
            return  DateTime.Now.ToString("yyMMddHHmmss") + "-" + DateTime.Now.Millisecond.ToString() + "-" + num.ToString();

        }
        public bool AddUserOrder(List<T301_Order_MainEntity> orders)
        {
            T301_Order_MainBLLSub bll = new T301_Order_MainBLLSub();
            return bll.AddOrder(orders);
        }

         /// <summary>
        /// 获取用户订单
        /// </summary>
        /// <param name="uID">用户ID</param>
        /// <param name="orderstatus">订单状态</param>
        /// <param name="commentstatus">评论状态</param>
        /// <param name="prodtitle">商品名称</param>
        /// <param name="OrderTimeBegin">成交时间</param>
        /// <param name="OrderTimeEnd">成交时间</param>
        /// <param name="pageSize">每页显示条数</param>
        /// <param name="currentPageIndex">当前页</param>
        /// <param name="totalPages">总页数</param>
        /// <param name="totalCount">总条数</param>
        /// <returns></returns>
        public List<T301_Order_MainEntity> GetOrderByUid(int uID, EnumOrderStatus orderstatus, EnumCommentStatus commentstatus, string prodtitle, string OrderTimeBegin, string OrderTimeEnd, int pageSize, int currentPageIndex, out int totalPages, out int totalCount)
        {
            T301_Order_MainBLLSub bll = new T301_Order_MainBLLSub();
            return bll.GetOrderByUid(uID, orderstatus, commentstatus, prodtitle, OrderTimeBegin, OrderTimeEnd, pageSize, currentPageIndex, out  totalPages, out  totalCount);
        }
        /// <summary>
        /// 订单详情
        /// </summary>
        /// <param name="OMID"></param>
        /// <returns></returns>
        public T301_Order_MainEntity GetOrderInfo(int OMID, int uID)
        {
            T301_Order_MainBLLSub bll = new T301_Order_MainBLLSub();
            return bll.GetObjectByOMID(OMID, uID);
        }
        #endregion
    }
}
